package org.hackystat.devcathlon.ui.page.profile;

import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.panel.Fragment;
import org.apache.wicket.markup.html.panel.Panel;

/**
 * Information Box Panel. 
 * This is the common panel used across many sections of Devcathlon. 
 *  
 * @author Anthony Du
 * 
 */
public class InfoBoxPanel extends Panel {
  /** Support serialization. */
  private static final long serialVersionUID = 1L;
  /** Info Box header title. */
  private String title = "[title]";
  
  /**
   * Info Box Panel constructor given only the ID.
   * @param id unique DOM id
   */
  public InfoBoxPanel(String id) {
    super(id);
  }
  
  /**
   * Info Box Panel constructor.
   * @param id unique DOM id
   * @param title info box header title
   * @param content content of info box -- a replaceable Fragment
   */
  public InfoBoxPanel(String id, String title, Fragment content) {
    super(id);
    this.title = title;
    add(new Label("infoHeader", this.title));
    if (content != null) {
      add(content);
    }
  }
  
  /**
   * Info Box Panel constructor.
   * @param id unique DOM id
   * @param title info box header title
   * @param content content of info box -- a replaceable Panel
   */
  public InfoBoxPanel(String id, String title, Panel content) {
    super(id);
    this.title = title;
    add(new Label("infoHeader", this.title));
    if (content != null) {
      add(content);
    }
  }
  
  /**
   * Set the info box title.
   * @param title info box title
   */
  public void setTitle(String title) {
    this.title = title;
    addOrReplace(new Label("infoHeader", this.title));
  }
  
  /**
   * Set the info box content panel.
   * @param content content of info box
   */
  public void setContent(Panel content) {
    addOrReplace(content);
  }
}
